﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdGiMetafiler : OdGiConveyorNode
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGiMetafiler(IntPtr cPtr, bool cMemoryOwn) : base(GlobalsPINVOKE.OdGiMetafiler_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGiMetafiler obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdGiMetafiler()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdGiMetafiler(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public override OdGiConveyorInput input()
		{
			OdGiConveyorInput result = new OdGiConveyorInput_Internal(GlobalsPINVOKE.OdGiConveyorNode_input(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public override OdGiConveyorOutput output()
		{
			OdGiConveyorOutput result = new OdGiConveyorOutput_Internal(GlobalsPINVOKE.OdGiConveyorNode_output(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdGiMetafiler cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiMetafiler_cast(OdRxObject.getCPtr(pObj));
			OdGiMetafiler result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiMetafiler)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiMetafiler)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiMetafiler)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiMetafiler_desc(), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiMetafiler_isA(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiMetafiler_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdGiMetafiler createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiMetafiler_createObject();
			OdGiMetafiler result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiMetafiler)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiMetafiler)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiMetafiler)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void setMetafile(OdGiGeometryMetafile pMetafile)
		{
			GlobalsPINVOKE.OdGiMetafiler_setMetafile(this.swigCPtr, OdGiGeometryMetafile.getCPtr(pMetafile));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual OdGiGeometryMetafile metafile()
		{
			OdGiGeometryMetafile result = (OdGiGeometryMetafile)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiMetafiler_metafile(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void exchangeMetafile(OdGiGeometryMetafile pMetafile)
		{
			GlobalsPINVOKE.OdGiMetafiler_exchangeMetafile(this.swigCPtr, OdGiGeometryMetafile.getCPtr(pMetafile));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void setDeviation(OdGeDoubleArray deviations)
		{
			GlobalsPINVOKE.OdGiMetafiler_setDeviation__SWIG_0(this.swigCPtr, OdGeDoubleArray.getCPtr(deviations));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void setDeviation(OdGiDeviation pDeviation)
		{
			GlobalsPINVOKE.OdGiMetafiler_setDeviation__SWIG_1(this.swigCPtr, pDeviation.GetCPtr());
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void setDrawContext(OdGiConveyorContext pDrawCtx)
		{
			GlobalsPINVOKE.OdGiMetafiler_setDrawContext(this.swigCPtr, pDrawCtx.GetCPtr());
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void setCoordinatesType(OdGiMetafiler.CoordType ct)
		{
			GlobalsPINVOKE.OdGiMetafiler_setCoordinatesType(this.swigCPtr, (int)ct);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual OdGiMetafiler.CoordType coordinatesType()
		{
			OdGiMetafiler.CoordType result = (OdGiMetafiler.CoordType)GlobalsPINVOKE.OdGiMetafiler_coordinatesType(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool saveTraits(OdGiSubEntityTraitsData entTraits, OdGiSubEntityTraitsData byBlockTraits)
		{
			bool result = GlobalsPINVOKE.OdGiMetafiler_saveTraits__SWIG_0(this.swigCPtr, OdGiSubEntityTraitsData.getCPtr(entTraits), OdGiSubEntityTraitsData.getCPtr(byBlockTraits));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool saveTraits(OdGiSubEntityTraitsData entTraits)
		{
			bool result = GlobalsPINVOKE.OdGiMetafiler_saveTraits__SWIG_1(this.swigCPtr, OdGiSubEntityTraitsData.getCPtr(entTraits));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool saveTraits()
		{
			bool result = GlobalsPINVOKE.OdGiMetafiler_saveTraits__SWIG_3(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void flush(bool bForceTraits)
		{
			GlobalsPINVOKE.OdGiMetafiler_flush__SWIG_0(this.swigCPtr, bForceTraits);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void flush()
		{
			GlobalsPINVOKE.OdGiMetafiler_flush__SWIG_1(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void add(OdGiGeometryMetafile.Record pRec)
		{
			GlobalsPINVOKE.OdGiMetafiler_add(this.swigCPtr, OdGiGeometryMetafile.Record.getCPtr(pRec));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		private object locker = new object();

		private HandleRef swigCPtr;

		public enum CoordType
		{
			kUnknown,
			kModel,
			kWorld,
			kEye,
			kDevice
		}
	}
}
